Repository navigation
fix(security)!: deny requests when no auth mode is enabled and validate JWT iss/aud - #193
Merged
Merged
Conversation
…te JWT iss/aud Fail-closed fallback - Only the public and webhook filter chains declare a request matcher. When jwt, oauth2-login, api-key and mock are all disabled, /api/v1/** matched no chain and was served without authentication or authorization. - Add FallbackDenyAllFilterChainConfig: registered only when no mode is enabled, lowest precedence, denies every remaining request and logs a warning at startup. JWT issuer and audience - The decoder validated signature and timestamps only, so any token signed by the identity provider was accepted, including tokens issued for other applications. - Add optional app.security.authentication.jwt.issuer-uri (OAUTH_ISSUER_URI) and .audiences (OAUTH_AUDIENCES). When set, iss and aud are validated. When unset, behaviour is unchanged and a warning is logged. BREAKING CHANGE: a deployment or local profile that runs with every authentication mode disabled now gets 403 on the API instead of open access.
Code coverage overviewLanguages: Java Java / code-coverage/jacoco
View coverage of the 2 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
evebrnd
approved these changes
Nov 18, 2026
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



PR Description
What this PR Provides
Two authentication hardening fixes. They are in one PR because they touch the same configuration area; the two parts are independent and can be reviewed separately.
1. Fail closed when no authentication mode is enabled
jwt,oauth2-login,api-key,mock) is conditional on its own flag. With all flagsfalse, as inapplication-local.yml,/api/v1/**matched no filter chain and was served with no authentication and no authorization.FallbackDenyAllFilterChainConfig. It is registered only when none of the four modes is enabled, has the lowest precedence, denies every remaining request, and logs a warning at startup.Checked on a running instance with every mode disabled, no token:
GET /api/v1/entity-templatesPOST /api/v1/entity-templatesGET /actuator/healthGET /v3/api-docsPOST /webhooks/unknown2. Validate the JWT issuer and audience
JwtConfigurationbuilt the decoder with the JWKS URI only, so tokens were checked for signature and timestamps. Any token signed by the identity provider was accepted, including tokens issued for other applications.app.security.authentication.jwt.issuer-uriOAUTH_ISSUER_URIissmust matchapp.security.authentication.jwt.audiencesOAUTH_AUDIENCES(comma-separated)audmust contain at least one valueBreaking change
app.security.authentication.mock.enabled=true.Tests
FallbackDenyAllFilterChainConfigTest: chain present with no property, present with all modes explicitly off, absent when any one mode is on (6 cases).JwtConfigurationTest: nothing configured, expired token, wrong issuer, wrong audience, missing audience (5 cases)../mvnw verify: 1,690 tests, 0 failures.docs/src/concepts/authentication.mdupdated.Not covered here
oauth2-login.enabled=truewithout aClientRegistrationRepositorybean: the OAuth2 chain is skipped by@ConditionalOnBeanwhile the fallback sees the flag as enabled. I did not reproduce this case; it deserves its own test.emailclaim withoutemail_verified; the admin allow-list is not issuer-scoped. Separate change.jwtandoauth2-login, both@Order(2)and any-request) is not addressed.Fixes
Found during the idp-core audit of 2026-11-17.
Review
The reviewer must double-check these points:
!after the type/scope to identify the breaking change